<%@page contentType="text/html;charset=UTF-8" language="java" import="java.util.*"%><%@ include file="../common/taglibs.jsp"%>
   <%
    	String usertype = (String)session.getAttribute(Config.USER_TYPE);
    	String flag = (String)session.getAttribute("flag");
    	int utype = 0;
    	if(!Utils.isNull(usertype)){
    		utype = Integer.valueOf(usertype);
    	}
    	String userid = (String)session.getAttribute(Config.USER_ID);
   %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title>
    <link href="../ui/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" /> 
    <link href="../ui/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../ui/lib/ligerUI/skins/Gray/css/dialog.css" rel="stylesheet" type="text/css" />
	<script src="../ui/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>  
	<script src="../ui/lib/ligerUI/js/ligerui.all.min.js" type="text/javascript"></script> 
    <script src="../ui/lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script> 
    <script src="../ui/lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script> 
    <script src="../ui/lib/jquery-validation/messages_cn.js" type="text/javascript"></script> 
    <script type="text/javascript"> 
        var eee;
        $(function () {	
        	$("form").ligerForm();
        	$("#customerID").ligerGetTextBoxManager().setDisabled(); 
        	<%
				String action = request.getParameter("action");
				String title = "添加客户";
				String required = "required:true,";
				String url="cust";
				String listJsp=jspName.replace("info","list");
			 	if(!"add".equals(action)){
					title = "查看客户信息";
					action = "t=";
					required = ""; 
			 %>		
		 
					$("#sex_<s:property value='customer.sex'/>").ligerRadio().setValue(true);
					$("#state_<s:property value='customer.state'/>").ligerRadio().setValue(true);
					$("#customerIDtr").show();
				 
					 $("#residualValue").ligerGetTextBoxManager().setDisabled(); 
			 <%		
				}else{
					action = "save";
			%>	
		 
        		$("#sex_0").ligerRadio().setValue(true);
        		$("#state_0").ligerRadio().setValue(true);
			<%}
				action = url+"?t="+Math.random()*10000;
			%>
			<%if(action.contains("save")){%>
			var v = $("form").validate({
                debug: false,
                rules: {
                    "customer.customerID": {minlength:3,maxlength:15,remote:'<%=url%>?action=check&t='+Math.random(100000)},
					"customer.name":{<%=required%>minlength:2,maxlength:10 },
					
					"customer.telephone":{required:true,minlength:6,maxlength:20,remote:'<%=url%>?action=checkTelephone&t='+Math.random(100000) },
					                                      <%-- "user.uid": {required:true,minlength:3,maxlength:10,remote:'<%=url%>?action=check&old='+'<s:property value="user.uid"/>'+'&t='+Math.random(100000)}, --%>       
					"customer.phone":{minlength:6,maxlength:20 },
					"customer.qq":{required:true,minlength:4,maxlength:20,remote:'<%=url%>?action=checkQq&t='+Math.random(100000)},
					"customer.address":{minlength:6,maxlength:40 },
					"customer.residualValue":{minlength:1,maxlength:10 },
					"customer.company":{required:true},
					"customer.sex":{required:true}
                },
			<%}else{%>
			var v = $("form").validate({
                debug: false,
                rules: {
                    "customer.customerID": {minlength:3,maxlength:15},
					"customer.name":{<%=required%>minlength:2,maxlength:10 },
					
					"customer.telephone":{required:true,minlength:6,maxlength:20},
					                                      <%-- "user.uid": {required:true,minlength:3,maxlength:10,remote:'<%=url%>?action=check&old='+'<s:property value="user.uid"/>'+'&t='+Math.random(100000)}, --%>       
					"customer.phone":{minlength:6,maxlength:20 },
					"customer.qq":{required:true,minlength:4,maxlength:20},
					"customer.address":{minlength:6,maxlength:40 },
					"customer.residualValue":{minlength:1,maxlength:10 },
					"customer.company":{required:true},
					"customer.sex":{required:true}
                },
			<%}%>
                errorPlacement: function (lable, element) {

                    if (element.hasClass("l-text-field")) {
                        element.parent().addClass("l-text-invalid");
                    }
                    var nextCell = element.parents("td:first").next("td");
                    if (nextCell.find("div.l-exclamation").length == 0) {
                        $('<div class="l-exclamation" title="' + lable.html() + '"></div>').appendTo(nextCell).ligerTip();
                    }
                },
                invalidHandler: function (form, validator) {
                    var errors = validator.numberOfInvalids();
                    if (errors) {
                        var message = errors == 1
                          ? '您有一处填写错误. 请根据提示修改。'
                          : '您有' + errors + ' 处填写错误. 请根据提示修改。';
                        $("#errorLabelContainer").html(message).show();
                    }
                },
                success: function (lable) {
                    var element = $("#" + lable.attr("for"));
                    var nextCell = element.parents("td:first").next("td");
                    if (element.hasClass("l-text-field")) {
                        element.parent().removeClass("l-text-invalid");
                    }
                    nextCell.find("div.l-exclamation").remove();
                },
                submitHandler: function (form) {
                    $("#errorLabelContainer").html("").hide();
                    form.submit();
                }
            });
            
            $(".l-button-test").click(function ()
            {
            	location.href = "<%=listJsp%>" ; 
            	
            });
        });  
    </script>
    <style type="text/css">
           body{ font-size:12px;}
        .l-table-edit {}
        .l-table-edit-td{ padding:4px;}
        .l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
        .l-verify-tip{ left:230px; top:120px;}
        #errorLabelContainer{ padding:10px; width:300px; border:1px solid #FF4466; display:none; background:#FFEEEE; color:Red;}
    </style>

</head>

<body style="padding:20px">

    <form name="form1" method="post" class="l-form" id="form1" action="<%=action%>" >

<div class="l-group l-group-hasicon">
<img src="../ui/lib/ligerUI/skins/icons/communication.gif"/>
<span><h2><%=title%></h2></span>
</div>
<div id="errorLabelContainer" class="l-text-invalid">
</div>
<table cellpadding="0" cellspacing="0" class="l-table-edit"  align="left" >
            <tr id="customerIDtr">
                <td align="right" class="l-table-edit-td">* 客户ID:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.customerID" id="customerID" ltype="text" value="<s:property value='customer.customerID'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">* 姓名:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.name" id="name" ltype="text" value="<s:property value='customer.name'/>" /></td>  <td align="left"></td>
            </tr>
             <tr>
                <td align="right" class="l-table-edit-td">客户状态:</td>
                <td align="left" class="l-table-edit-td">
                <input id="state_0" type="radio" name="customer.state" value="0"   /><label for="state_0">启用</label> 
                <input id="state_1" type="radio" name="customer.state" value="1"  /><label for="state_1">停用</label>
                <!-- <input id="state_2" type="radio" name="customer.state" value="2"  /><label for="state_2">已转移(停用)</label>  -->
                </td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">* 公司名称:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.company" id="company" ltype="text" value="<s:property value='customer.company'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">性别:</td>
                <td align="left" class="l-table-edit-td">
                <input id="sex_1" type="radio" name="customer.sex" value="1"   /><label for="sex_1">男</label> 
                <input id="sex_0" type="radio" name="customer.sex" value="0"  /><label for="sex_0">女</label> 
                </td>
            </tr>
             <% if(utype==Config.USER_TYPE_TOP_MANERGER){ %>
              <tr>
                <td align="right" class="l-table-edit-td">* 手机号码:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.telephone" id="telephone" ltype="text" value="<s:property value='customer.telephone'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">电话号码:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.phone" id="phone" ltype="text" value="<s:property value='customer.phone'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">* QQ号:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.qq" id="QQ" ltype="text" value="<s:property value='customer.qq'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">地址:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.address" id="address" ltype="text" value="<s:property value='customer.address'/>" /></td>  <td align="left"></td>
            </tr>
            <%} else{ if(flag.equals("true")&&(utype==Config.USER_TYPE_COMMON || utype== Config.USER_TYPE_COMMON_MANERGER)){%>
             <tr>
                <td align="right" class="l-table-edit-td">* 手机号码:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.telephone" id="telephone" ltype="text" value="<s:property value='customer.telephone'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">电话号码:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.phone" id="phone" ltype="text" value="<s:property value='customer.phone'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">* QQ号:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.qq" id="QQ" ltype="text" value="<s:property value='customer.qq'/>" /></td>  <td align="left"></td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">地址:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.address" id="address" ltype="text" value="<s:property value='customer.address'/>" /></td>  <td align="left"></td>
            </tr>
            <%} }%>
            <%-- <tr>
                <td align="right" class="l-table-edit-td">* 操作员:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.operator" id="operator" ltype="text" value="<s:property value='customer.operator'/>" /></td>  <td align="left"></td>
            </tr> --%>
            <tr>
                <td align="right" class="l-table-edit-td">剩余金额:</td>
                <td align="left" class="l-table-edit-td"><input name="customer.residualValue" id="residualValue" ltype="text" value="<s:property value='customer.residualValue'/>" /></td>  <td align="left"></td>
            </tr>
           <tr>
           <td>
          
           </td>
           <td>
            <input type="button" value="取消" class="l-button l-button-test"/>
           </td>
           </tr>
        </table>

 <br />

    </form>

    <div style="display:none">
    <!--  数据统计代码 --></div>

    
</body>
</html>